home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 2 / Gekikoh Dennoh Club Vol. 2 (Japan).7z / Gekikoh Dennoh Club Vol. 2 (Japan) (Track 01).bin / kowin / font / fonted31.lzh / fed3pop.c < prev    next >
C/C++ Source or Header  |  1990-11-24  |  3KB  |  124 lines

  1. /*/ ******************************************************************* /*/
  2. /*/                                    /*/
  3. /*/       FONTED3.win    version 1    小笠原博之 SPS0783 COR.    /*/
  4. /*/                                    /*/
  5. /*/ ******************************************************************* /*/
  6.  
  7. #include    <stdio.h>
  8. #include    <wlib.h>
  9. #include    <parts.h>
  10. #include    <winop.h>
  11.  
  12. #include    "fed3const.h"
  13. #include    "fonted3.h"
  14.  
  15. char    *savemenu[]={
  16.         "PED include",
  17.         "PED source",
  18.         "GBACK file",
  19.         "bit image"
  20.     };
  21.  
  22. extern    lineinput();
  23.  
  24. savefont( wp )
  25. WindowID    wp;
  26. {
  27.     int        mode,
  28.             i;
  29.     unsigned int    x,
  30.             y;
  31.     FILE        *fp;
  32.     char        inputbuf[80];
  33.     unsigned short    imgbuf[16];
  34.     char        abuf[40];
  35.     char        bbuf[80];
  36.  
  37.     for( x=0 ; x<16 ; x++ )
  38.         imgbuf[x]= ~ImgBuf[x];
  39.  
  40.     x= MS_CURGT();
  41.     y= x & 0xffff;
  42.     x >>= 16;
  43.     mode= PopUpMenu( x-2, y+1, savemenu, 4, 12 );
  44.  
  45.     if( mode >= 0 ){
  46.         *inputbuf= '\0';
  47.         areamsg( wp, "ファイル名?  " );
  48.         lineinput( inputbuf );
  49.         if( *inputbuf == '\0' ){
  50.             areamsg( wp, 0 );
  51.             return    FALSE;
  52.         }
  53.         if( mode < 2 )
  54.             strmfe( bbuf, inputbuf, mode==1 ? "c" : "inc" );
  55.         else
  56.             strcpy( bbuf, inputbuf );
  57.         if( (fp= fopen( bbuf, "wb" ))== 0 ){
  58.             areamsg( wp, "open error! " );
  59.             return    FALSE;
  60.         }
  61.         stcgfn( abuf, inputbuf );
  62.         areamsg( wp, "セーブ中    " );
  63.         switch( mode ){
  64.             case 1:
  65.                 fputs( "#include \"wlib.h\"\r\n\r\n", fp );
  66.             case 0:
  67.                 fprintf( fp, "static\tshort\t%s1[] = {\r\n\t", abuf ); /* } */
  68.                 for( i=0 ; i<15 ; i++ )
  69.                     fprintf( fp, "0x%04X, ", ImgBuf[i] );
  70.     /* { */            fprintf( fp, "0x%04X\r\n};\r\n", ImgBuf[15] );
  71.  
  72.                 fprintf( fp, "static\tshort\t%s2[] = {\r\n\t", abuf ); /* } */
  73.                 for( i=0 ; i<15 ; i++ )
  74.                     fputs( "0x0000, ", fp );
  75.     /* { */            fprintf( fp, "0x0000\r\n};\r\n%sSheet\t%sPattern = { 16, 16, 1, %s1, %s2 };\r\n", mode==1?"":"static\t", abuf, abuf, abuf );
  76.                 break;
  77.  
  78.             case 2:
  79.                 putw( 16, fp );
  80.                 putw( 16, fp );
  81.                 fwrite( ImgBuf, 32, 1, fp );
  82.                 break;
  83.  
  84.             case 3:
  85.                 fwrite( imgbuf, 32, 1, fp );
  86.                 break;
  87.         }
  88.         fclose( fp );
  89.         areamsg( wp, "セーブ終了" );
  90.         return    TRUE;
  91.     }
  92. }
  93.  
  94.  
  95. loadfont( fname )
  96. char    *fname;
  97. {
  98.     FILE    *fp;
  99.  
  100.     if( fp= fopen( fname, "rb" ) ){
  101.         if( getc(fp) < ' ' ){
  102.             fseek( fp, 4, 0 );
  103.             fread( ImgBuf, 32, 1, fp );
  104.         }else{
  105.             unsigned short    *data= ImgBuf;
  106.             int    i;
  107.             char    sbuf[200];
  108.             freopen( fname, "r", fp );
  109.             while( fgets( sbuf, 200, fp ) )
  110.                 if( strncmp( sbuf, "static", 6 ) == 0 )
  111.                     break;
  112.             for( i= 0 ; i< 16 ; i++ ){
  113.                 int    a;
  114.                 fscanf( fp, "0x%X, ", &a );
  115.                 *data++= a;
  116.             }
  117.         }
  118.         fclose( fp );
  119.         return    TRUE;
  120.     }
  121.     return    FALSE;
  122. }
  123.  
  124.